﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NetFrame.LogService
{
    class Log
    {

        public static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("loginfo");   //选择<logger name="loginfo">的配置 

        public static readonly log4net.ILog logerror = log4net.LogManager.GetLogger("logerror");   //选择<logger name="logerror">的配置 

        public static void SetConfig()
        {
            log4net.Config.XmlConfigurator.Configure();
        }

        public static void SetConfig(FileInfo configFile)
        {
            log4net.Config.XmlConfigurator.Configure(configFile);
        }

        public static void Info(string info)
        {
            if (loginfo.IsInfoEnabled)
            {
                loginfo.Info(info);
            }
        }

        public static void Error(Exception ex)
        {
            if (logerror.IsErrorEnabled)
            {
                logerror.Error(ex.Message, ex);
            }
        }   
        
       

        private static void Append( string text)
        {
            File.AppendAllText("Log" + DateTime.Today.ToString("yyyy-MM-dd") + ".txt", text);
        }
    }
}
